package com.inlycat.utils;

public class Condition {

	private String propertyName;
	private Object value;
	private String operator;

	/**
	 * 等于
	 * @param propertyName
	 * @param value
	 * @return
	 */
	public static Condition eq(String propertyName, Object value) {
		Condition c = new Condition();
		c.setPropertyName(propertyName);
		c.setValue(value);
		c.setOperator("=");

		return c;
	}

	/**
	 * 小于
	 * @param propertyName
	 * @param value
	 * @return
	 */
	public static Condition lt(String propertyName, Object value) {
		Condition c = new Condition();
		c.setPropertyName(propertyName);
		c.setValue(value);
		c.setOperator("<");

		return c;
	}

	/**
	 * 大于
	 * @param propertyName
	 * @param value
	 * @return
	 */
	public static Condition gt(String propertyName, Object value) {
		Condition c = new Condition();
		c.setPropertyName(propertyName);
		c.setValue(value);
		c.setOperator(">");

		return c;
	}
	
	/**
	 * 大于等于
	 * @param propertyName
	 * @param value
	 * @return
	 */
	public static Condition ge(String propertyName, Object value) {
		Condition c = new Condition();
		c.setPropertyName(propertyName);
		c.setValue(value);
		c.setOperator(">=");
		return c;
	}
	
	/**
	 * 小于等于
	 * @param propertyName
	 * @param value
	 * @return
	 */
	public static Condition le(String propertyName, Object value){
		Condition c = new Condition();
		c.setPropertyName(propertyName);
		c.setValue(value);
		c.setOperator("<=");
		return c;
	}

	/**
	 * like
	 * @param propertyName
	 * @param value
	 * @return
	 */
	public static Condition like(String propertyName, Object value) {
		Condition c = new Condition();
		c.setPropertyName(propertyName);
		c.setValue(value);
		c.setOperator("like");

		return c;
	}

	/**
	 * between small and big
	 * @param propertyName
	 * @param small
	 * @param big
	 * @return
	 */
	public static Condition between(String propertyName, Object small,
			Object big) {
		Condition c = new Condition();
		c.setPropertyName(propertyName);
		c.setValue(small);
		c.setValue(big);
		c.setOperator("BETWEEN ? AND");

		return c;
	}

	public String getPropertyName() {
		return propertyName;
	}

	public void setPropertyName(String propertyName) {
		this.propertyName = propertyName;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	public String getOperator() {
		return operator;
	}

	public void setOperator(String operator) {
		this.operator = operator;
	}

}
